#include "StdAfx.h"
#include "Logger.h"

using namespace std;
Logger::Logger( int nBufferSize , wstring strLogFile )
{
	m_pBuffer = new ThreadSafeBuffer();
	m_pBuffer->Init( nBufferSize , strLogFile );
}

bool Logger::WriteTraceInfo( wstring message )
{
	message = wstring(L"TRACE INFO:") + message + wstring(L"\n");
	m_pBuffer->Write( message.c_str() , message.length() );
	return 0;
}
bool Logger::WriteErrorInfo( wstring message )
{
	message = wstring(L"ERROR:") + message + wstring(L"\n");
	m_pBuffer->Write( message.c_str() , message.length() );
	return 0;
}
bool Logger::WriteFatalInfo( wstring message )
{
	message = wstring(L"FATAL ERROR:") + message + wstring(L"\n");
	m_pBuffer->Write( message.c_str() , message.length() );
	m_pBuffer->CloseFile();
	return 0;
}
Logger::~Logger(void)
{
	m_pBuffer->CloseFile();
	delete( m_pBuffer );
}
